package com.example.finalwork.Income;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.finalwork.DAO.IncomeDAO;
import com.example.finalwork.Entity.Income;
import com.example.finalwork.LoginActivity;
import com.example.finalwork.R;
import com.example.finalwork.lmpl.IncomeDAOlmpl;

import java.util.List;

public class IncomeGetAllActivity extends AppCompatActivity implements View.OnClickListener{
    private LinearLayout ll_content;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_incomegetall);

        findViewById(R.id.button3).setOnClickListener(this);

        ll_content = findViewById(R.id.ll_content);

        IncomeDAO incomeDAO = new IncomeDAOlmpl(this);
        List<Income> incomes = incomeDAO.GetAllIncome();
        for(int i = 0 ; i < incomes.size() ; i++)
        {
            Income income = incomes.get(i);
            if(LoginActivity.data.equals(income.getIn_User()))
            {
                TextView textView1 = new TextView(this);
                textView1.setText("\t\t\t\t\t\t"+String.valueOf(income.getIn_id()) + "\t\t\t\t\t\t\t\t\t\t\t\t" + income.getIn_Name() + "\t\t\t\t\t\t\t\t\t\t" + income.getIn_Date() + "\t\t\t\t\t\t\t\t\t" + income.getIn_Amount() + "\t\t\t\t\t\t\t\t\t" + income.getIn_Remark());
                textView1.setTextSize(18);
                ll_content.addView(textView1);
            }
        }
        setTitle("查看所有收入项目功能");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button3:
                Toast.makeText(this,"返回上一级",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(this,IncomeMainActivity.class));
                break;
        }
    }
}
